package com.zhaodm.practise.webview;

import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.webkit.WebSettings;
import android.webkit.WebView;

@SuppressLint("SetJavaScriptEnabled")
public class MiniBrowser extends Activity {
	
	private static final String TAG = MiniBrowser.class.getSimpleName();
	private WebView show = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mini_browser);
        
        show = (WebView)findViewById(R.id.show);
        
        WebSettings settings = show.getSettings();
        Log.i(TAG, "==========1===========");
        settings.setJavaScriptEnabled(true);
        
        show.addJavascriptInterface(new PersonalData(), "abc");
        
        show.loadUrl("http://10.0.2.2:8080/webview_test/test.html");
    }
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_mini_browser, menu);
        return true;
    }
    
    public class PersonalData {
    	
    	public PersonalData() {
    		
    	}
    	
    	public int getAge() {
    		return age;
    	}
    	
    	public String getName() {
    		Log.i(TAG, "==========2222===========");
    		return name;
    	}
    	
    	private int age = 28;
    	private String name = "I love lihui!!";
    }
}
